﻿Public Class Todo

    Private _id As Integer = -1
    Private _task As String
    Private _note As String
    Private _noteYN As Boolean
    Private _priority As Byte
    Private _dueDate As Date
    Private _dueYN As Boolean
    Private _completedDatedYN As Boolean
    Private _completedDatedDate As Date
    Private _category As Integer
    Private _sortString As String
    Private _sortDueString As String
    Private _sortExecString As String
    Private _private As Boolean

    Private _todoDAL As TodoDAL

    Property Id() As Integer
        Get
            Return _id
        End Get
        Set(ByVal value As Integer)
            _id = value
        End Set
    End Property

    Property Task() As String
        Get
            Return Me._task
        End Get
        Set(ByVal value As String)
            Me._task = value
        End Set
    End Property

    Property Note() As String
        Get
            Return _note
        End Get
        Set(ByVal value As String)
            _note = value
        End Set
    End Property

    Property NoteYN() As Boolean
        Get
            Return _noteYN
        End Get
        Set(ByVal value As Boolean)
            _noteYN = value
        End Set
    End Property

    Property Priority() As Byte
        Get
            Return _priority
        End Get
        Set(ByVal value As Byte)
            _priority = value
        End Set
    End Property

    Property DueDate() As String
        Get
            Return _dueDate
        End Get
        Set(ByVal value As String)
            _dueDate = value
        End Set
    End Property

    Property DueDateYN() As Boolean
        Get
            Return _dueYN
        End Get
        Set(ByVal value As Boolean)
            _dueYN = value
        End Set
    End Property

    Property CompletedDatedYN() As Boolean
        Get
            Return _completedDatedYN
        End Get
        Set(ByVal value As Boolean)
            _completedDatedYN = value
        End Set
    End Property

    Property CompletedDatedDate() As String
        Get
            Return _completedDatedDate
        End Get
        Set(ByVal value As String)
            _completedDatedDate = value
        End Set
    End Property

    Property Category() As String
        Get
            Return _category
        End Get
        Set(ByVal value As String)
            _category = value
        End Set
    End Property


    Property IsPrivate() As Boolean
        Get
            Return _private
        End Get
        Set(ByVal value As Boolean)
            _private = value
        End Set
    End Property

    Property Pri() As String
        Get
            Return Convert.ToString(Convert.ToInt32(Me.IsPrivate))
        End Get
        Set(ByVal value As String)

        End Set
    End Property


    Property SortString() As String
        Get
            Return _sortString
        End Get
        Set(ByVal value As String)
            _sortString = value
        End Set
    End Property


    Property SortDueString() As String
        Get
            Return _sortDueString
        End Get
        Set(ByVal value As String)
            _sortDueString = value
        End Set
    End Property

    Property SortExecString() As String
        Get
            Return _sortExecString
        End Get
        Set(ByVal value As String)
            _sortExecString = value
        End Set
    End Property

    Public Sub New()
        If (g_sDbName IsNot Nothing) Then
            _todoDAL = New TodoDAL(g_sDbName)
        End If
    End Sub

    Public Function save() As Boolean
        Try
            If (_id = -1) Then
                _todoDAL.Insert(Me)
            Else
                _todoDAL.Update(Me)
            End If
        Catch ex As Exception
            Throw New Exception(ex.Message)
        End Try
        
    End Function

    Public Sub GetDataTable()
        _todoDAL.GetDataTable()
    End Sub

    Public Function getData() As Todo()
        Return _todoDAL.GetData()
    End Function
End Class
